import requests

from libs import config

if __name__ == '__main__':
    api_host = f'http://127.0.0.1:{config.get_env('gpm_api_port', 19995)}/api/v3'

    url = f'{api_host}/profiles?group_id=3&page=1&per_page=200'
    resp = requests.get(url).json()

    proxy_stat = {}

    profiles = resp.get('data')
    print(f'profile_count={len(profiles)}')

    for profile in profiles:
        proxy = profile['raw_proxy']
        if proxy not in proxy_stat:
            proxy_stat[proxy] = 1
        else:
            proxy_stat[proxy] = proxy_stat.get(proxy, 0) + 1

    for proxy in proxy_stat:
        print(f"{proxy} => {proxy_stat.get(proxy)}")